package sz.szsmk.citizencard.ui.dialogs;

import android.app.Dialog;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;

import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import sz.szsmk.citizencard.R;
import sz.szsmk.citizencard.util.CircleCrop;
import sz.szsmk.citizencard.util.GlideRoundTransform;
import sz.szsmk.citizencard.util.JumpThirdView;

/**
 * Copyright (c)2021/4/23
 * author: hxh
 * created on: 2021/4/23 14:21
 * description:
 */
public class ShowADDialog extends Dialog {


    private Dialog dialog;
    private View view;
    private ImageView pic;
    private int round=0;
    private static ShowADDialog showADDialog=null;

    public ShowADDialog(@NonNull Context context) {
        super(context);
    }
    public static ShowADDialog getInstance(Context context){
        if (showADDialog==null)
            return new ShowADDialog(context);
        else
            return showADDialog;
    }

    public void show(Context context,String url,String jumpUrl){
//        View view = LayoutInflater.from(context).inflate(R.layout.show_ad_dialog, null);
//        AlertDialog dialog = new AlertDialog.Builder(context).setView(view).create();
//        dialog.setCanceledOnTouchOutside(false);
//        dialog.show();

        dialog = new Dialog(context, R.style.Translucent_NoTitle);
        view = LayoutInflater.from(context).inflate(R.layout.show_ad_dialog, null);
        pic = view.findViewById(R.id.ad_pic);
        ImageView close = view.findViewById(R.id.ad_close);
        round=30;
        GlideRoundTransform glideRoundTransform = new GlideRoundTransform(context, 30);
        Glide.with(context).load(url).bitmapTransform(new RoundedCornersTransformation(context,30,0)).into(pic);
        close.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                dialog.dismiss();
            }
        });
        pic.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                JumpThirdView.baseToJumpView(context, jumpUrl, "",0, "");
            }
        });

        dialog.setCancelable(false);
        dialog.setContentView(view);
        dialog.show();

    }
}
